<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box {
      position: fixed;
      box-shadow: 0px 0px 5px 1px rgba(0, 0, 0, 0.3);
      width: 100px;
      height: 100px;
    }
    .btn{
      position: fixed;
      right: 0;
      bottom: 0;
    }
  </style>
</head>

<body>
  <div id="app">
    <!-- 
      对象语法绑定style 
        :style="{CSS属性 : 属性值}"
    -->
    <div class="box" :style="{left:left+'px',top:top+'px'}">
      <div :style="[{color:'red',fontSize:'20px'},{backgroundColor:'pink'}]">文本文本</div>
    </div>
    <div class="btn">
      <button @click="toTop">↑</button>
      <button @click="toBottom">↓</button>
      <button @click="toLeft">←</button>
      <button @click="toRight">→</button>
    </div>
  </div>
  <script src="./js/vue.js"></script>
  <script>
    const app = new Vue({
      el: "#app",
      data: function () {
        return {
          left: 0,
          top: 0 ,
          step: 10
        }
      },
      methods: {
        toTop() {
          this.top -= this.step
        },
        toRight() {
          this.left += this.step
        },
        toBottom() {
          this.top += this.step
        },
        toLeft() {
          this.left -= this.step
        },
      }
    })
  </script>
</body>

</html>